DB window state

How do you set the window state of a DB?
Maximize, Minimize, Restore
 

void DoSetMaxClick(DB oDB) {
    print("????\n")
}
void DoIsMaxClick(DB oDB) {
        print("Max: " (isMaximized(oDB)) "\n")
}
 
DB oDB = create("Title")
apply(oDB, "SetMax", DoSetMaxClick)
apply(oDB, "IsMax", DoIsMaxClick)
show(oDB)

SystemAdmin - Thu Feb 28 07:23:15 EST 2013

Re: DB window state
llandale - Thu Feb 28 10:42:17 EST 2013

I don't see anything.

I played around with the script below; which will print the current size if you manually maximize the dialog and hit the button. The displayed size seems to be the current screen resolution+12. I wonder if that helps.
 

DB db
 
void buttonSize(DBE dbexx)
{
   int w = 0, h = 0
   getSize(db, w, h)
print w "x" h "\t"
   if (w < 200) //
   then setSize(db, 2000, 3000)
   else setSize(db, 100, 200)
}
 
db = create("Resize")
button(db, "Resize", buttonSize)
show(db)


-Louie

Re: DB window state
Mathias Mamsch - Fri Mar 01 04:13:31 EST 2013

Could not find a function for this either. Is it important? Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Re: DB window state
SystemAdmin - Fri Mar 01 05:47:08 EST 2013

Mathias Mamsch - Fri Mar 01 04:13:31 EST 2013
Could not find a function for this either. Is it important? Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Not important really - just a nice to have.
I have quite a large, resizeable DB which is used quite often. Most people immediatly maximise it.
It would have been nice to auto maximise the DB on loading it because offsite users with laptops have a much lower resolution screen, and so just setting the size means it overflows the screen.

Re: DB window state
llandale - Sat Mar 02 17:09:21 EST 2013

SystemAdmin - Fri Mar 01 05:47:08 EST 2013
Not important really - just a nice to have.
I have quite a large, resizeable DB which is used quite often. Most people immediatly maximise it.
It would have been nice to auto maximise the DB on loading it because offsite users with laptops have a much lower resolution screen, and so just setting the size means it overflows the screen.

Well then ... all you need to do is get the primary screen's resolution and set the box size vis-a-vis that size. That's so easy I'll let someone else tell you how. ;)

-Louie

Re: DB window state
Mathias Mamsch - Sun Mar 03 14:47:33 EST 2013

llandale - Sat Mar 02 17:09:21 EST 2013
Well then ... all you need to do is get the primary screen's resolution and set the box size vis-a-vis that size. That's so easy I'll let someone else tell you how. ;)

-Louie

Googling brought up the following command:
 

cmd /c wmic desktopmonitor get screenheight, screenwidth

 


Maybe it is worth experimenting with, regards, Mathias

 

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

 

Re: DB window state
llandale - Mon Mar 04 12:45:16 EST 2013

Mathias Mamsch - Sun Mar 03 14:47:33 EST 2013

Googling brought up the following command:
 

cmd /c wmic desktopmonitor get screenheight, screenwidth

 


Maybe it is worth experimenting with, regards, Mathias

 

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

 

So you invoke that with DXL, read and parse the results, and adjust the dialog box for THIS client based on that?

Re: DB window state
Mathias Mamsch - Mon Mar 04 17:00:00 EST 2013

llandale - Mon Mar 04 12:45:16 EST 2013
So you invoke that with DXL, read and parse the results, and adjust the dialog box for THIS client based on that?

Well you can access the WMI also over COM which might be more DXL-esce ... See for example here:

http://stackoverflow.com/questions/7967699/get-screen-resolution-using-wmi-powershell-in-windows-7

but yeah, could be a possibility. Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Re: DB window state
Tony_Goodman - Tue Mar 05 05:07:18 EST 2013

Mathias Mamsch - Mon Mar 04 17:00:00 EST 2013
Well you can access the WMI also over COM which might be more DXL-esce ... See for example here:

http://stackoverflow.com/questions/7967699/get-screen-resolution-using-wmi-powershell-in-windows-7

but yeah, could be a possibility. Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

My preferred approach would be to use COM, but I could not get it to work.

The following does the job. I have not added any error checking which I would recommend.

Note that if you have two monitors, you will need to be more clever about extracting the results.
 

void getScreenResolution(int &w, int &h)
{
    Regexp reWidth = regexp2 "ScreenWidth=([0-9]*)"
        Regexp reHeight = regexp2 "ScreenHeight=([0-9]*)"
        
        string sResult = ""
        win32SystemWait_("cmd /c wmic desktopmonitor get screenheight, screenwidth /value >&2", sResult, -1)
        
        if (reWidth sResult) w = intOf(sResult[match 1])
        if (reHeight sResult) h = intOf(sResult[match 1])
}
 
int w = 0
int h = 0
getScreenResolution(w, h)
 
print "ScreenWidth = " w "\n"
print "ScreenHeight = " h "\n"

 


Tony Goodman, www.smartdxl.com

 

Re: DB window state
Tony_Goodman - Tue Mar 05 05:20:35 EST 2013

Tony_Goodman - Tue Mar 05 05:07:18 EST 2013

My preferred approach would be to use COM, but I could not get it to work.

The following does the job. I have not added any error checking which I would recommend.

Note that if you have two monitors, you will need to be more clever about extracting the results.
 

void getScreenResolution(int &w, int &h)
{
    Regexp reWidth = regexp2 "ScreenWidth=([0-9]*)"
        Regexp reHeight = regexp2 "ScreenHeight=([0-9]*)"
        
        string sResult = ""
        win32SystemWait_("cmd /c wmic desktopmonitor get screenheight, screenwidth /value >&2", sResult, -1)
        
        if (reWidth sResult) w = intOf(sResult[match 1])
        if (reHeight sResult) h = intOf(sResult[match 1])
}
 
int w = 0
int h = 0
getScreenResolution(w, h)
 
print "ScreenWidth = " w "\n"
print "ScreenHeight = " h "\n"

 


Tony Goodman, www.smartdxl.com

 

I tried this on a dialog and there is no guarantee that the dialog is centered on the screen, and I cannot get setPos() or setCenteredSize() to work properly.

This may be due to my dual-screen setup.
 

void getScreenResolution(int &w, int &h)
{
    Regexp reWidth = regexp2 "ScreenWidth=([0-9]*)"
        Regexp reHeight = regexp2 "ScreenHeight=([0-9]*)"
        
        string sResult = ""
        win32SystemWait_("cmd /c wmic desktopmonitor get screenheight, screenwidth /value >&2", sResult, -1)
        
        if (reWidth sResult) w = intOf(sResult[match 1])
        if (reHeight sResult) h = intOf(sResult[match 1])
}
 
DB db = null
 
int w = 0, h = 0
getScreenResolution(w, h)
 
db = create("Resize")
realize(db)
setCenteredSize(db, w, h)
setPos(db, 0, 0)
show(db)

 


Tony Goodman, www.smartdxl.com

 

Re: DB window state
Tony_Goodman - Tue Mar 05 05:55:18 EST 2013

Tony_Goodman - Tue Mar 05 05:20:35 EST 2013

I tried this on a dialog and there is no guarantee that the dialog is centered on the screen, and I cannot get setPos() or setCenteredSize() to work properly.

This may be due to my dual-screen setup.
 

void getScreenResolution(int &w, int &h)
{
    Regexp reWidth = regexp2 "ScreenWidth=([0-9]*)"
        Regexp reHeight = regexp2 "ScreenHeight=([0-9]*)"
        
        string sResult = ""
        win32SystemWait_("cmd /c wmic desktopmonitor get screenheight, screenwidth /value >&2", sResult, -1)
        
        if (reWidth sResult) w = intOf(sResult[match 1])
        if (reHeight sResult) h = intOf(sResult[match 1])
}
 
DB db = null
 
int w = 0, h = 0
getScreenResolution(w, h)
 
db = create("Resize")
realize(db)
setCenteredSize(db, w, h)
setPos(db, 0, 0)
show(db)

 


Tony Goodman, www.smartdxl.com

 

I thought I had forgotten something here...
see https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14239123&#14239123

setPos() does not work with zeroes.

use setPos(db, 1, 1) and it works.

Tony Goodman, www.smartdxl.com

Re: DB window state
SystemAdmin - Wed Mar 06 04:57:35 EST 2013

Tony_Goodman - Tue Mar 05 05:55:18 EST 2013
I thought I had forgotten something here...
see https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14239123&#14239123

setPos() does not work with zeroes.

use setPos(db, 1, 1) and it works.

Tony Goodman, www.smartdxl.com

Thanks for all the work.

Unfortunatly, WMIC.exe is restricted to admins on the pc here.
I know it is possible to get the screen dimensions via automating Internet Explorer instead, but I recall there were the same problems with duel screens.

I have been too busy to check wmi, as it is low,low,low priority.

Re: DB window state
Mathias Mamsch - Wed Mar 06 06:41:58 EST 2013

SystemAdmin - Wed Mar 06 04:57:35 EST 2013
Thanks for all the work.

Unfortunatly, WMIC.exe is restricted to admins on the pc here.
I know it is possible to get the screen dimensions via automating Internet Explorer instead, but I recall there were the same problems with duel screens.

I have been too busy to check wmi, as it is low,low,low priority.

I remember I had to use the WMI from DXL once, so since COM does not seem to work, i think I wrote the vb script to a temp file, executed it via cscript /nologo ... and then parsed the output.
 

strComputer = "." 
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") 
Set colItems = objWMIService.ExecQuery( _
    "SELECT * FROM Win32_DesktopMonitor",,48) 
For Each objItem in colItems 
    Wscript.Echo "-----------------------------------"
    Wscript.Echo "Win32_DesktopMonitor instance"
    Wscript.Echo "-----------------------------------"
    Wscript.Echo "ScreenHeight: " & objItem.ScreenHeight
    Wscript.Echo "ScreenWidth: " & objItem.ScreenWidth
Next

 


So since the above VBS seems to work, it should be easy to adapt the output to be parsed more easily and write it to a vbs file and call it instead of calling the WMIC command directly. Regards, Mathias

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS